package com.itfly.service;

import com.itfly.entity.EventCategories;
import com.itfly.mapper.EventCategoriesMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EventCategoriesService {
    @Autowired
    private EventCategoriesMapper eventCategoriesMapper;

    public List<EventCategories> findCategoryById(Integer id) {
        List<EventCategories> eventCategories = eventCategoriesMapper.selectById(id);
        return eventCategories;
    }

    public int insertCategory(EventCategories eventCategories) {
        return eventCategoriesMapper.insertCategory(eventCategories);
    }
    //根据categoryName查询
    public EventCategories selectByName(String categoryName, Integer userId) {
        return eventCategoriesMapper.selectByName(categoryName,userId);
    }
    //查询分类
    public EventCategories selectById(Integer id) {
        return eventCategoriesMapper.selectByCategoryId(id);
    }
    //更新
    public void updateCategory(String categoryName, Integer id) {
        eventCategoriesMapper.updateByPrimaryKey(categoryName,id);
    }

    public int deleteCategory(Integer id) {
        return eventCategoriesMapper.deleteCategory(id);
    }
}
